const db = wx.cloud.database()

Page({

  /**
   * 页面的初始数据
   */
  data: {

    icon:[{
      name:'right',
      isShow:true
    }],
    g_list: [{
        img: 'https://image.meiye.art/FhtISupNHMibBgrGZOe15CPQ-d5R?imageMogr2/thumbnail/450x/interlace/1',
      },
      {
        img: 'https://image.meiye.art/FgaFNs-YNxw_vRtqCbvQru3z6s3P?imageMogr2/thumbnail/450x/interlace/1',
      },
      {
        img: 'https://image.meiye.art/FqZALKFWQ7vEZtmJyMyB_w776B_H?imageMogr2/thumbnail/450x/interlace/1',
      },
      {
        img: 'https://image.meiye.art/FhtISupNHMibBgrGZOe15CPQ-d5R?imageMogr2/thumbnail/450x/interlace/1',
      },
      {
        img: 'https://image.meiye.art/FgaFNs-YNxw_vRtqCbvQru3z6s3P?imageMogr2/thumbnail/450x/interlace/1',
      },
      {
        img: 'https://image.meiye.art/FqZALKFWQ7vEZtmJyMyB_w776B_H?imageMogr2/thumbnail/450x/interlace/1',
      },
    ],
    d_num: 3,
    news_list:[],
    content_list:[],

  },

  jump:function(){
    wx.navigateTo({
      url: '../index/search/search',
    })
  },

  big_data:function(){
    wx.navigateTo({
      url: './addition/bigdata/bigdata',
    })
  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getNews();
    this.getContent();
  },

  getNews:function(){
    db.collection('news').get().then(res =>{
      
      this.setData({
        news_list:res.data
      })
    })
  },

  goToDetail: function (e) {
    const id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: `/pages/index/news_detail/news_detail?_id=${id}`
    });
  },

  getContent:function(){
    db.collection('feature').get().then(res =>{
      this.setData({
        content_list:res.data
      })
    })
  },

  goToContent:function(e){
    const id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url:  `/pages/index/feature/feature?_id=${id}`,
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  }
})